<template>
  <div class="tab-container">
    <div
      class="nowrap-text"
      v-for="tab in tabList"
      :key="tab.id"
      :class="{ active: tab.id === currentIndex }"
      @click="selectTab(tab.id)"
    >
      {{ tab.label }}
    </div>
  </div>
</template>

<script>
export default {
  name: 'Tab',
  props: ['currentIndex'],
  data () {
    return {
      tabList: [
        { id: 1, label: '业绩榜' },
        { id: 2, label: '企业统计' },
        { id: 3, label: '我的记录' },
      ]
    }
  },

  mounted () {

  },

  methods: {
    selectTab (id) {
      this.$emit('select', id)
    }
  }
}
</script>

<style scoped>
.tab-container {
  height: 82px;
  line-height: 82px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: url("../../../../assets/images/tab.png") no-repeat center;
  background-size: 100% 100%;
  color: #afafaf;
  font-size: 20px;
  font-weight: 500;
  text-align: center;
  padding: 0 10px;
  z-index: 5;
}
.tab-container div {
  width: calc(100% / 3);
  text-align: center;
}
.active {
  width: 100%;
  height: 62px;
  line-height: 62px;
  background: url("../../../../assets/images/selected.png") no-repeat center;
  background-size: 100% 100%;
  margin-bottom: 5px;
  color: #e04125;
  font-weight: 600;
}
</style>